package com.example.shiroredisdemo.config;

import org.apache.shiro.cache.AbstractCacheManager;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @Author: Anita
 * @Date: Created in 19:07 2018/1/6
 */
public class ShiroRedisCacheManager extends AbstractCacheManager {
    private RedisTemplate<byte[],byte[]> shiroRedisTemplate;

    public ShiroRedisCacheManager(RedisTemplate<byte[],byte[]> shiroRedisTemplate){
        this.shiroRedisTemplate = shiroRedisTemplate;
    }
    @Override
    protected Cache<byte[],byte[]> createCache(String name) throws CacheException {
        return new ShiroRedisCache<byte[], byte[]>(shiroRedisTemplate,name);
    }
}